diff options
Diffstat (limited to 'app/[lng]/partners/(partners)/po/[id]/page.tsx')
| -rw-r--r-- | app/[lng]/partners/(partners)/po/[id]/page.tsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/app/[lng]/partners/(partners)/po/[id]/page.tsx b/app/[lng]/partners/(partners)/po/[id]/page.tsx new file mode 100644 index 00000000..8df2c90e --- /dev/null +++ b/app/[lng]/partners/(partners)/po/[id]/page.tsx @@ -0,0 +1,55 @@ +import * as React from "react" +import { getServerSession } from "next-auth/next" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" +import { redirect } from "next/navigation" +import { getVendorContractDetail } from "@/lib/po/vendor-table/service" +import { Shell } from "@/components/shell" +import { ContractDetailClient } from "./contract-detail-client" + +interface ContractDetailPageProps { + params: Promise<{ + id: string + lng: string + }> +} + +export default async function ContractDetailPage(props: ContractDetailPageProps) { + const params = await props.params + const contractId = parseInt(params.id, 10) + + // 유효하지 않은 ID 체크 + if (isNaN(contractId) || contractId <= 0) { + return ( + <Shell className="gap-4"> + <div className="flex h-full items-center justify-center p-6"> + <p className="text-muted-foreground">유효하지 않은 계약 ID입니다.</p> + </div> + </Shell> + ) + } + + // 세션에서 벤더 정보 가져오기 + const session = await getServerSession(authOptions) + if (!session?.user?.companyId) { + redirect("/") + } + + // 계약 상세 정보 조회 + const result = await getVendorContractDetail(contractId, session.user.companyId) + + if (!result.success || !result.data) { + return ( + <Shell className="gap-4"> + <div className="flex h-full items-center justify-center p-6"> + <p className="text-muted-foreground">{result.error || "계약 정보를 찾을 수 없습니다."}</p> + </div> + </Shell> + ) + } + + return ( + <Shell className="gap-4"> + <ContractDetailClient contract={result.data} lng={params.lng} /> + </Shell> + ) +} |
